﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;

namespace SqlMidasala
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        sql Sql = new sql(); //sql stuffa
        Globals g = new Globals();
        view w;

        public Window1()
        {
            InitializeComponent();
            if (!Sql.SetLink())
                MessageBox.Show("Tókst ekki að koma á tengingu við gagnagrunn","Villa í tengingu",MessageBoxButton.OK,MessageBoxImage.Error);
            Sql.ReadTable();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List<string> listinn = new List<string>();
            listinn = Sql.GetTableList();

            for (int i = 0; i < listinn.Count; i++)
                comboBox1.Items.Add(listinn[i]);
        }

        private void buttonAddGuest_Click(object sender, RoutedEventArgs e)
        {
            string id = textBoxID.Text;
            string name = textBoxName.Text;
            string pNumber = textBoxPNumber.Text;
            string info = textBoxInfo.Text;
            Sql.AddGuset(id, name, pNumber, info);
        }

        private void buttonView_Click(object sender, RoutedEventArgs e)
        {
            Sql.UpdateLists();
            w = new view();
            w.Show();
        }
    }
}
